package net.simflow.swf.analyzer.gui;

import java.util.Collection;
import java.util.Map;

import net.simflow.swf.analyzer.data.StringConstant;

import org.eclipse.swt.custom.StyledText;

public class ErrorChecker {
	private static ErrorChecker instance = new ErrorChecker();

	private ErrorChecker() {
	}

	public static ErrorChecker getInstance() {
		return instance;
	}

	public boolean isNull(Object o, StyledText text, String name) {
		if (o == null) {
			Printer.getInstance().append(text, name + " doesn't exist.",
					StringConstant.WARNING, Printer.COLOR_WARNING);
			return true;
		} else {
			return false;
		}
	}

	public boolean isEmpty(Collection<? extends Object> c, StyledText text,
			String name) {
		if (c.isEmpty()) {
			Printer.getInstance().append(text, name + " is empty.",
					StringConstant.WARNING, Printer.COLOR_WARNING);
			return true;
		} else {
			return false;
		}
	}

	public boolean isEmpty(Map<? extends Object, ? extends Object> m,
			StyledText text, String name) {
		if (m.isEmpty()) {
			Printer.getInstance().append(text, name + " is empty.",
					StringConstant.WARNING, Printer.COLOR_WARNING);
			return true;
		} else {
			return false;
		}
	}
}
